package com.github.data_manage.dao

import com.github.data_manage.domain.po.UserMessage
import org.springframework.data.jpa.repository.Modifying
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param

interface UserMessageDao: BaseDao<UserMessage> {

    fun findAllByUserId(userId: Int): List<UserMessage>

    @Modifying
    @Query("UPDATE UserMessage SET alreadyRead = true WHERE userId = :userId")
    fun readAllByUserId(@Param("userId") userId: Int)

    @Modifying
    fun removeAllByUserId(@Param("userId") userId: Int)
}